﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Automobile.service.BLL;
using Automobile.service.Model;
using Automobile.service.Common;
using System.Web.Script.Serialization;
using System.Web.SessionState;

namespace Automobile.service.UI.Hander
{
    /// <summary>
    /// Handler1 的摘要说明
    /// </summary>
    public class Handler1 : IHttpHandler,IRequiresSessionState
    {

        public void ProcessRequest(HttpContext context)
        {
            SupplierBLL Sbll = new SupplierBLL();
            MemberCardBLL Mbll = new MemberCardBLL();
            JournalBLL jbll = new JournalBLL();
            context.Response.ContentType = "text/plain";
            string url = context.Request["url"].ToString();
            switch (url)
            {
                case "delsup":
                    context.Response.Write(Sbll.DelSupplier(context.Request["str"].ToString())); //根据ID删除供应商
                    jbll.AddJourna_DelSupplier(Convert.ToInt32(context.Session["empid"]), context.Request["str"].ToString());
                    break;
                case "delMem":
                    context.Response.Write(Mbll.DelMemberCard(context.Request["str"].ToString()));//根据ID删除会员信息
                    jbll.AddJourna_DelMemberCard(Convert.ToInt32(context.Session["empid"]), context.Request["str"].ToString());
                    break;
                case "UptState":
                    int MemberCard_Id = Convert.ToInt32(context.Request["MemberCard_Id"]);
                    int MemberCard_State = Convert.ToInt32(context.Request["MemberCard_State"]);
                    context.Response.Write(Mbll.UptMemberCard_StateByID(MemberCard_Id,MemberCard_State));//修改会员状态
                    jbll.AddJourna_UptMemberCard_StateByID(Convert.ToInt32(context.Session["empid"]), MemberCard_Id);
                    break;
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}